import { renderOverflowText } from '../common/Format';

/**排序*/
const getSorter = (prev: Record<string, any>, next: Record<string, any>): number => (prev > next ? 1 : -1);

export const SourcingColumns = [
  {
    title: '采购项目名称',
    dataIndex: 'projectName',
    key: 'projectName',
    width: 130,
    visible: true,
    fixed: 'left',
    render: (text: string) => renderOverflowText(text, true),
  },
  {
    title: '标的名称',
    dataIndex: 'packName',
    key: 'packName',
    width: 130,
    visible: true,
    fixed: 'left',
    render: (text: string) => renderOverflowText(text, true),
  },
  {
    title: '标的类型',
    dataIndex: 'materialTypeName',
    key: 'materialTypeName',
    width: 150,
    visible: true,
    render: (text: string) => renderOverflowText(text, true),
  },
  {
    title: '规格型号（参数）',
    dataIndex: 'needParams',
    key: 'needParams',
    width: 180,
    visible: true,
    render: (text: string) => renderOverflowText(text, true),
  },
  {
    title: '标的类别',
    dataIndex: 'supplyKindName',
    key: 'supplyKindName',
    width: 150,
    visible: true,
    render: (text: string) => renderOverflowText(text, true),
  },
  {
    title: '数量',
    dataIndex: 'expectNum',
    key: 'expectNum',
    width: 120,
    visible: true,
    render: (text: string, record: Record<string, any>) => {
      return (
        <span>
          {renderOverflowText(text)}
          {record.unitBusiness ?? '个'}
        </span>
      );
    },
  },
  {
    title: '预估单价（元）',
    dataIndex: 'expectPrice',
    key: 'expectPrice',
    width: 180,
    visible: true,
    render: (text: number) => renderOverflowText(text),
  },
  {
    title: '预估总价（元）',
    dataIndex: 'expectSum',
    key: 'expectSum',
    width: 180,
    visible: true,
    render: (text: string) => renderOverflowText(text),
  },
];
